local cuimian = fk.CreateSkill {
  name = "th_cuimian",
  max_phase_use_time = 1,
}

cuimian:addEffect("active", {
  name = "th_cuimian",
  anim_type = "control",
  prompt = "#th_cuimian",
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_num = 2,
  target_filter = function(self, player, to_select, selected)
    return #selected < 2 and (#selected ~= 0 or not to_select:isKongcheng())
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local tos = effect.tos
    local card_data = {}
    for _, to in ipairs(tos) do
      local cards = to:getCardIds("h")
      if #cards ~= 0 then
        table.insert(card_data, { to.general, cards })
      end
    end
    if #card_data == 0 then return end
    local cid = room:askToChooseCard(player, {
      target = tos[1],
      flag = { card_data = card_data },
      skill_name = cuimian.name,
      prompt = '#th_cuimian'
    })
    room:moveCards({
      ids = { cid },
      from = room:getCardOwner(cid),
      toArea = Card.Processing,
      moveReason = fk.ReasonJustMove,
      skillName = cuimian.name,
      proposer = player.id,
    })
    room:sendFootnote({ cid }, {
      type = "$$TurnOverCard",
      from = player.id,
    })
    local card = Fk:getCardById(cid)
    local _, ret = room:askToUseActiveSkill(player, {
      skill_name = "#th_cuimian_active",
      prompt = '#th_cuimian-active:::' .. card:toLogString(),
      cancelable = false,
      extra_data = {
        skillName = cuimian.name,
        card_id = cid,
        targets = table.map(tos, Util.IdMapper),
        extra_data = {
          bypass_distances = true,
          bypass_times = true
        }
      }
    })
    if not ret then return end
    if ret.targets[2] then
      room:useCard{
        from = ret.targets[1],
        tos = { ret.targets[2] },
        card = card
      }
    else
      room:obtainCard(ret.targets[1], cid, nil, fk.ReasonPrey, player.id, cuimian.name)
    end
  end
}, { check_skill_limit = true })

Fk:loadTranslationTable{
  ["th_cuimian"] = "催眠",
  [":th_cuimian"] = "出牌阶段限一次，你可以观看两名角色的手牌（只需其中一名角色有手牌）并亮出其中一张，然后你选择令其中一名角色：1.对另一方使用此牌；2.获得此牌。",

  ["#th_cuimian"] = "催眠：观看两名角色的手牌并选择其中一张牌，令此牌被使用或被获得",

  ["#th_cuimian-active"] = "催眠：请选择此 %arg 是被使用还是被获得",
}

return cuimian